package org.oslims.client.view.impl;

import org.oslims.client.uicomponents.editbox.SelectDeadlineBox;
import org.oslims.client.uicomponents.editbox.ShowPlaningBox;
import org.oslims.client.view.AnalysisPlaningView;
import org.oslims.domain.Analysis;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Tree;
import com.google.gwt.user.client.ui.VerticalPanel;

public class AnalysisPlaningViewImpl extends BaseViewImpl implements AnalysisPlaningView {

	private final Tree samplesTree = new Tree();
	private final CellTable<Analysis> analysisTable = new CellTable<Analysis>();
	private final Label noAnalysisDefined = new Label("No Analysis found for the selection");
	private final SelectDeadlineBox deadlineBox = new SelectDeadlineBox();
	private final ShowPlaningBox planingBox = new ShowPlaningBox();
	private Button addAnalysis = new Button("Add Analysis");

	public AnalysisPlaningViewImpl() {

		DockLayoutPanel content = new DockLayoutPanel(Unit.PCT);
		content.setStyleName("mainContent");

		Label header = new Label("Analysis Planing");
		header.setStyleName("viewHeader");

		content.addNorth(header, 5);

		VerticalPanel vpAnalysisPanel = new VerticalPanel();
		vpAnalysisPanel.add(noAnalysisDefined);

		ScrollPanel spAnalysisTable = new ScrollPanel();
		spAnalysisTable.add(analysisTable);
		vpAnalysisPanel.add(spAnalysisTable);

		content.addEast(vpAnalysisPanel, 40);

		content.addSouth(addAnalysis, 5);

		ScrollPanel spSamplesTree = new ScrollPanel();
		spSamplesTree.add(samplesTree);
		content.add(spSamplesTree);

		initWidget(content);

	}

	@Override
	public Tree getSamplesTree() {
		return samplesTree;
	}

	public CellTable<Analysis> getAnalysisList() {
		return analysisTable;
	}

	@Override
	public Label getNoAnalysisAvailableLabel() {
		return noAnalysisDefined;
	}

	@Override
	public HasClickHandlers getPlanAnalysisButton() {
		return addAnalysis;
	}

	@Override
	public SelectDeadlineBox getSelectDeadlineBox() {
		return deadlineBox;

	}

	@Override
	public ShowPlaningBox getPlaningBox() {
		return planingBox;
	}

}
